<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui"
      xmlns:ui="http://java.sun.com/jsf/facelets"> 

<h:head>
	<title>TravelDream Home</title>
	<h:outputStylesheet library="TdTheme" name="css/style.css"/> 	
</h:head>
<h:body>
	<h:form>  
	    <p:menubar>  
	        <p:submenu label="Inserisci prodotti" icon="ui-icon-document">  
	            <p:menuitem value="Hotel" icon="ui-icon-contact" url="crea_hotel.xhtml?faces-redirect=true"/>  
	            <p:menuitem value="Escursioni" icon="ui-icon-contact" url="crea_escursione.xhtml?faces-redirect=true"/>
	            <p:menuitem value="Voli" icon="ui-icon-contact" url="crea_volo.xhtml?faces-redirect=true"/>  
	        </p:submenu>  
	  
	        <p:submenu label="Gestisci prodotti" icon="ui-icon-document">  
	            <p:menuitem value="Hotel" icon="ui-icon-contact" url="cerca_hotel.xhtml?faces-redirect=true"/>  
	            <p:menuitem value="Escursioni" icon="ui-icon-contact" url="cerca_escursioni.xhtml?faces-redirect=true"/>
	            <p:menuitem value="Voli" icon="ui-icon-contact" url="cerca_voli.xhtml?faces-redirect=true"/>  
	        </p:submenu>  
	  
	        <p:submenu label="Pacchetti Preconfigurati" icon="ui-icon-document">  
	            <p:menuitem value="Crea" url="crea_pp.xhtml?faces-redirect.xhtml"/>  
	            <p:menuitem value="Gestisci" url="gestione_pp.xhtml?faces-redirect=true" />  
	        </p:submenu>    
	  
	        <f:facet name="options">  
	            <p:commandButton value="Logout" icon="ui-icon-extlink" action="#{loginManagedBean.logout()}"/>  
	        </f:facet>  
	    </p:menubar>  
  	</h:form>  	
  	<h:form>
	<p:messages id="messaggio" showDetail="true" autoUpdate="true" closable="true" /> 
	</h:form>
	<h:panelGrid styleClass="userTopBar">
		<p:panel>
			<h:form id="search_form">
				<h:panelGrid columns = "5">
					<h:outputLabel value="Data Partenza: Da: " />
					<p:calendar value="#{searchPacchettoManagedBean.dataFrom}" id="fromD" navigator="true" mindate="#{searchPacchettoManagedBean.getTodayDate()}" label="Da:" >
						<p:ajax event="dateSelect" update="toD"/>
					</p:calendar>
					<h:outputLabel value="A: " style="margin-left:50px;"/>
					<p:calendar id="toD" value="#{searchPacchettoManagedBean.dataTo}" navigator="true" mindate="#{searchPacchettoManagedBean.dataFrom}" label="A:">
						<f:attribute name="startDate" value="#{searchPacchettoManagedBean.dataFrom}"/>
						<f:validator validatorId="dateRangeValidator"/>
					</p:calendar>
					<br/>
					<h:outputLabel value="Destinazione:" />
					<p:inputText value="#{searchPacchettoManagedBean.destinazione}" id="destInput"/>
					<p:outputLabel>Escludi pacchetti non in vendita: </p:outputLabel>
					<p:selectBooleanCheckbox value="#{searchPacchettoManagedBean.escludiNonInVendita}"/>
					<p:commandButton value="Cerca" action="#{searchPacchettoManagedBean.searchPP()}">
						<f:ajax render="searchOutput"/>
					</p:commandButton>  
				</h:panelGrid>
				<p:messages showDetail="true" autoUpdate="true"/>
				<p:dataTable id="searchOutput" var="p" value="#{searchPacchettoManagedBean.searchResult}">
  						<p:column headerText="Immagine">
                    		<img style="width:100px" src="../resources/TdTheme/img/hotel.png"/>
                		</p:column>
						
						<p:column headerText="Nome">
		                    <h:outputText value="#{p.nome}"/>
		                </p:column>
		                
		                <p:column headerText="Destinazione">
		                    <h:outputText value="#{p.destinazione_pacchetto}"/>
		                </p:column>
		                
		                <p:column headerText="Prezzo">
		                	<h:outputText value="#{p.getPrezzoBase()} euro"/>
		                </p:column>
		                
		                <p:column headerText="Stato" rendered="#{!searchPacchettoManagedBean.escludiNonInVendita}">
		                	<h:outputText value="In vendita" rendered="#{p.inVendita}" style="color:#00F;"/>
		                	<h:outputText value="Non in vendita" rendered="#{!p.inVendita}" style="color:#F00;" />
		                </p:column>
                		
		                <p:column>
		                	<p:commandButton value="Elimina" action="#{searchPacchettoManagedBean.eliminaPP(p)}"/>
		                	<p:commandButton value="Metti in vendita" action="#{searchPacchettoManagedBean.cambiaStatoInVendita(p)}" rendered="#{!searchPacchettoManagedBean.isInVendita(p)}"/>
		                	<p:commandButton value="Rimuovi dalla vendita" action="#{searchPacchettoManagedBean.cambiaStatoInVendita(p)}" rendered="#{searchPacchettoManagedBean.isInVendita(p)}"/>
		                </p:column>
                </p:dataTable>	
			</h:form>
		</p:panel>
	</h:panelGrid>
	
</h:body> 
</html>
